package com.springstudy.beans;


import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * @author Tamako
 * @since 2025/1/9 16:29
 */
//@Component
public class OtherBean {
    @Bean(name = "dataSource")
    public DataSource dataSource(
            @Value("${jdbc.driver}") String driverClassName) {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl("jdbc:mysql://localhost:3306/easychat");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        return dataSource;
    }
}
